package com.paradise.ytj.utils;

import android.app.Activity;
import android.app.Dialog;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/1/29 0029.
 */

public class DialogUtils {

    private static List<Dialog> oList = new ArrayList<>();

    /**
     * 添加Dialog
     */
    public static void addDialog(Dialog dialog) {
        if (oList == null) {
            oList = new ArrayList<>();
        }
        if (!oList.contains(dialog)) {
            oList.add(dialog);
        }
    }

    /**
     * 销毁单个Dialog
     */
    public static void removeDialog(Dialog dialog) {
        if (oList == null) {
            oList = new ArrayList<>();
        }
        if (oList.contains(dialog)) {
            oList.remove(dialog);
            dialog.dismiss();
        }
    }

    /**
     * 销毁所有的Dialog
     */
    public static void removeALLDialog() {
        if (oList == null) {
            oList = new ArrayList<>();
        }
        for (Dialog dialog : oList) {
            dialog.dismiss();
        }
    }
}
